package chapter2.No2_2_synchronized同步语句块.i静态同步方法与synchronized_class代码块.demo1;

/**
 * Created by Administrator on 2016/11/12.
 */
public class ServiceClass {
    public synchronized static void methodA() {
        try {
            System.out.println("线程"+Thread.currentThread().getName()+"进入A");
            Thread.sleep(500);
            System.out.println("线程"+Thread.currentThread().getName()+"退出A");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized static void methodB() {
        try {
            System.out.println("线程"+Thread.currentThread().getName()+"进入B");
            Thread.sleep(500);
            System.out.println("线程"+Thread.currentThread().getName()+"退出B");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
